package mvc.effects.impl;

import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.LookupOp;
import java.awt.image.ShortLookupTable;

import mvc.effects.INonParameterizedEffect;

@SuppressWarnings("nls")
public class InvertEffect implements INonParameterizedEffect {
	
	private BufferedImageOp invert;
	private final String EFFECT_NAME = "Invert";

	public InvertEffect() {
		short[] data = new short[256];
		for (int i = 0; i < 256; i++) {
			data[i] = (short) (256 - i);
		}
		invert = new LookupOp(new ShortLookupTable(0, data), null);
	}

	@Override
	public BufferedImage applyEffect(BufferedImage img) {
		return invert.filter(img, null);
	}

	@Override
	public BufferedImageOp getEffect() {
		return invert;
	}

	
	@Override
	public String toString(){		
		return EFFECT_NAME;
	}
	
	
}
